﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AutoFix
{
    public partial class Calculate : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnCalculate_Click(object sender, EventArgs e)
        {
            Regex numberValidate = new Regex(@"^[0-9]*$");
            string numberOne = this.txtNumberOne.Text;
            string numberTwo = this.txtNumberTwo.Text;
            if (numberOne != string.Empty && numberTwo != string.Empty)
            {
                if (numberValidate.IsMatch(numberOne) && numberValidate.IsMatch(numberTwo))
                {
                    this.lblMessage.Text = "";
                    int numOne = Convert.ToInt16(numberOne);
                    int numTwo = Convert.ToInt16(numberTwo);
                    int sum = numOne + numTwo;
                    lblTotal.Text = "The Total is " + "<strong>" + sum.ToString() + "</strong>";
                }
                else
                {
                    this.lblTotal.Text = "";
                    this.lblMessage.Text = "Only numbers are allowed.";
                }
            }
            else
            {
                this.lblTotal.Text = "";
                this.lblMessage.Text = "Please enter numbers to calculate.";
            }
            this.txtNumberOne.Text = "";
            this.txtNumberTwo.Text = "";
        
        }
    }
}